﻿@using BlazorApp.Pages.Common.Html
@using BlazorApp.Pages.Common.Html.HTable
@using BlazorApp.Pages.Common.Metadata
@using BlazorApp.Pages.Event
@using BlazorApp.Pages.Pod
@using BlazorApp.Pages.Service
@inherits BlazorApp.Pages.Common.DrawerPageBase<k8s.Models.V1ReplicaSet>
@if (ReplicaSet != null)
{
    <ReplicaSetAction Item="ReplicaSet" MenuMode="MenuMode.Horizontal"></ReplicaSetAction>
    <Divider Orientation="left" Style="font-weight:bold">@L["Metadata"]</Divider>
    <MetadataView Item="ReplicaSet.Metadata" ExplainFieldPrefix="replicaSet"></MetadataView>
    <Divider Orientation="left" Style="font-weight:bold">@L["Spec"]</Divider>
    <HTable Bordered Column="1">
        <SelectorView Title=@L["Selector"] Selector="@ReplicaSet.Spec.Selector.MatchLabels"></SelectorView>
        <SelectorView Title=@L["Node Selector"] Selector="@ReplicaSet.Spec.Template.Spec.NodeSelector"></SelectorView>
        <ImagesView PodSpec="@ReplicaSet.Spec.Template.Spec"></ImagesView>
        <TolerationsView ExplainField="replicaSet.spec.template.spec.tolerations" Tolerations="@ReplicaSet.Spec.Template.Spec.Tolerations"></TolerationsView>
        <PropertySimpleView Title=@L["MinReadySeconds"] Item="@ReplicaSet.Spec.MinReadySeconds" ExplainField="replicaSet.spec.minReadySeconds"></PropertySimpleView>
        <PropertySimpleView Title=@L["Replicas"] Item="@ReplicaSet.Spec.Replicas" ExplainField="replicaSet.spec.replicas"></PropertySimpleView>
    </HTable>
    <PodTemplateView PodTemplate="@ReplicaSet.Spec.Template" MetadataExplainFieldPrefix="replicaSet"></PodTemplateView>

    <Divider Orientation="left" Style="font-weight:bold">@L["Status"]</Divider>
    <HTable Bordered Column="1">
        <HTableColumn Title=@L["Replicas"]>
            @($"{ReplicaSet.Status.AvailableReplicas ?? 0} {L["Current"]} / {ReplicaSet.Status.Replicas} {L["Desired"]}")
        </HTableColumn>
        <ConditionView ConditionList="@ReplicaSet.Status.Conditions" ExplainField="replicaSet.status.conditions"></ConditionView>
        <PropertySimpleView Title=@L["Replicas"] Item="@ReplicaSet.Status.Replicas" ExplainField="replicaSet.status.replicas"></PropertySimpleView>
        <PropertySimpleView Title=@L["AvailableReplicas"] Item="@ReplicaSet.Status.AvailableReplicas" ExplainField="replicaSet.status.availableReplicas"></PropertySimpleView>
        <PropertySimpleView Title=@L["FullyLabeledReplicas"] Item="@ReplicaSet.Status.FullyLabeledReplicas" ExplainField="replicaSet.status.fullyLabeledReplicas"></PropertySimpleView>
        <PropertySimpleView Title=@L["ObservedGeneration"] Item="@ReplicaSet.Status.ObservedGeneration" ExplainField="replicaSet.status.observedGeneration"></PropertySimpleView>
        <PropertySimpleView Title=@L["ReadyReplicas"] Item="@ReplicaSet.Status.ReadyReplicas" ExplainField="replicaSet.status.readyReplicas"></PropertySimpleView>

    </HTable>

    <MiniPodListView ControllerByUid="@ReplicaSet.Metadata.Uid"></MiniPodListView>
    @if (ReplicaSet.Spec?.Template.Metadata.Labels is { Count: > 0 })
    {
        <MiniServiceListView Labels="@ReplicaSet.Spec.Template.Metadata.Labels"></MiniServiceListView>
    }

    <MiniEventListView Uid="@ReplicaSet.Metadata.Uid"></MiniEventListView>
}
